package com.aube.rvi;

import android.graphics.Bitmap;
import android.view.View;

import com.aube.rvi.net.Response;
import com.aube.rvi.net.AubeError;
import com.aube.rvi.net.ResponseListener;

/**
 * Created by huyaonan on 16/10/25.
 */
public abstract class BitmapListener implements ResponseListener<Bitmap> {
    /**
     * Called when a response is received.
     */
    public abstract void onResponse(Bitmap response);

    /**
     * Callback method that an error has been occurred with the
     * provided error code and optional user-readable message.
     */
    public void onErrorResponse(AubeError error) {
        onErrorResponse();
    }

    public void onErrorResponse() {

    }

    public void onStart() {

    }

    /**
     * Is called when image loading task was started
     *
     * @param imageUri Loading image URI
     * @param view     View for image
     */
    public void onLoadingStarted(String imageUri, View view) {
        onStart();
    }

    /**
     * Is called when image is loaded successfully (and displayed in View if one was specified)
     *
     * @param imageUri    Loaded image URI
     * @param view        View for image. Can be <b>null</b>.
     * @param loadedImage Bitmap of loaded and decoded image
     */
    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
        onResponse(loadedImage);
    }

    /**
     * Is called when image loading task was cancelled because View for image was reused in newer task
     *
     * @param imageUri Loading image URI
     * @param view     View for image. Can be <b>null</b>.
     */
    public void onLoadingCancelled(String imageUri, View view) {

    }
}